package com.tougutips.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.tougutips.entity.SeckillOrder;
import com.tougutips.service.SeckillOrderService;

import java.util.List;

@RestController
@RequestMapping("/order")
public class SeckillOrderController {
    @Autowired
    private SeckillOrderService seckillOrderService;

    /**
     * 查询所有订单
     *
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list() {
        List<SeckillOrder> list = seckillOrderService.list();
        return AjaxResult.success(list);
    }

    /**
     * 新增订单
     *
     * @param goods
     * @return
     */
    @PostMapping
    public AjaxResult save(@RequestBody SeckillOrder goods) {
        boolean save = seckillOrderService.save(goods);
        if (save) return AjaxResult.success("新增商品成功");
        return AjaxResult.error("新增商品失败");
    }

}
